﻿using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using OpenAdmin.Core.DbContextLocators;

namespace OpenAdmin.Core.Models;

/// <summary>
/// 功能操作表
/// </summary>
[Table("SysOperation")]
public class SysOperation : EntityBase<ApplicationDbContextLocator>, IEntityTypeConfigure<SysOperation>
{
    /// <summary>
    /// 操作名称
    /// </summary>
    public string Name { get; set; }
    /// <summary>
    /// 操作编码
    /// </summary>
    public string Code { get; set; }
    /// <summary>
    /// 所属菜单Id
    /// </summary>
    public int MenuId { get; set; }
    /// <summary>
    /// 接口id
    /// </summary>
    public int ApiResourceId { get; set; }
    /// <summary>
    /// 父操作id
    /// </summary>
    public int ParentId { get; set; }
    /// <summary>
    /// 排序
    /// </summary>
    public int Sort { get; set; }

    public void Configure(EntityTypeBuilder<SysOperation> entityBuilder)
    {
        entityBuilder.Property(p => p.Name).HasMaxLength(50).IsRequired();
        entityBuilder.Property(p => p.Code).HasMaxLength(50);
    }
}
